import { Module } from "@nestjs/common";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
import { U1Controller } from "./u1/u1.controller";
import { UserModule } from "./user/user.module";
import { OrmModule } from "./orm/orm.module";
import { TypeOrmModule } from "@nestjs/typeorm";
import { ClientsModule, Transport } from "@nestjs/microservices";
import { VedioModule } from "./vedio/vedio.module";

@Module({
  imports: [
    ClientsModule.register([
      {
        name: "CALC_SERVICE",
        transport: Transport.TCP,
        options: {
          port: 8888,
        },
      },
    ]),
    UserModule,
    OrmModule,
    TypeOrmModule.forRoot({
      type: "mysql", //数据库类型
      username: "api2", //账号
      password: "api2", //密码
      host: "data2.masaikk.fun", //host
      port: 3307, //
      database: "nest", //库名
      // entities: [__dirname + "/**/*.entity{.ts,.js}"], //实体文件
      synchronize: true, //synchronize字段代表是否自动将实体类同步到数据库
      retryDelay: 500, //重试连接数据库间隔
      retryAttempts: 10, //重试连接数据库的次数
      autoLoadEntities: true, //如果为true,将自动加载实体 forFeature()方法注册的每个实体都将自动添加到配置对象的实体数组中
    }),
    VedioModule,
  ],
  controllers: [AppController, U1Controller],
  providers: [AppService],
})
export class AppModule {}
